package ua.races.dom.docBuilder;

import org.jdom.Element;
//import org.w3c.dom.Element;
import ua.races.vo.BetType;


import java.util.List;
import java.util.ListIterator;

public class BetTypeDocumentBuilder extends DocumentBuilder{

    protected List<BetType> betTypes;

    public BetTypeDocumentBuilder(List<BetType> betTypes) {
        this.betTypes = betTypes;
    }

    public void build() {
        BetType betType = null;

        Element root = new Element("betTypes");

        ListIterator<BetType> iterator = betTypes.listIterator();

        while (iterator.hasNext()) {
            Element betTypeElement = new Element("betType");
            betType = iterator.next();

            Element betTypeId = new Element("BetTypeID");
            betTypeId.setText(String.valueOf(betType.getBetTypeId()));
            betTypeElement.addContent(betTypeId);

            Element betTyp = new Element("BetType");
            betTyp.setText(betType.getBetType());
            betTypeElement.addContent(betTyp);

            betTypes.add(betType);
        }
        document.addContent(root);

    }
}
